package com.example.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.entity.Driver;
import com.example.mapper.DriverMapper;
import com.example.service.IDriverService;
import com.example.util.page2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author tyhxzy
 * @since 2023-11-03
 */
@Service
public class DriverServiceImpl  implements IDriverService {

    @Autowired
    private DriverMapper driverMapper;


    @Override
    public int insert(Driver driver) {
        return driverMapper.insert(driver);

    }

    @Override
    public Driver selectByPhone(String phone) {
        LambdaQueryWrapper<Driver> oo = new LambdaQueryWrapper<>();
        oo.eq(Driver::getPhone,phone);
        return driverMapper.selectOne(oo);
    }

    @Override
    public Driver update(Driver driver) {
        return driverMapper.update(driver);
    }

    @Override
    public int updatejifen(Driver driver) {
        return driverMapper.updateById(driver);
    }


    @Override
    public Page<Map> findByParams(page2 page) {
        Page p1 = new Page(page.getPageNo(), page.getPageSize());
        return driverMapper.findDriver(p1,page);
    }

    @Override
    public Map findByDid(Integer id) {
        return driverMapper.findByDid(id);
    }

    @Override
    public Map findDAllPoints(Integer id) {
        return driverMapper.findDAllPoints(id);
    }

    @Override
    public Driver SelectPassword(String passwd) {
        LambdaQueryWrapper<Driver> mm=new LambdaQueryWrapper<>();
        mm.eq(Driver::getPasswd,passwd);
        Driver driver = driverMapper.selectOne(mm);
        return driver;
    }


}
